package com.service.admin;

import com.service.admin.rabbitmq.binding.MatchSink;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <dl>
 * <dt>back-end</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年07月27日</dd>
 * </dl>
 *
 * @author
 */
@Slf4j
@EnableSwagger2
//@EnableScheduling
@ServletComponentScan
@SpringBootApplication
@ComponentScan("com.service.*")
@EnableTransactionManagement
@MapperScan("com.service.*.mapper")
@EnableBinding({ MatchSink.class})
public class AdminApplication {

    public static void main(String[] args) {
        log.info("业务模块启动中");
        SpringApplication.run(AdminApplication.class, args);
    }

    @Value("${swagger.enable}")
    private boolean enableSwagger;

    @Bean
    public Docket swaggerApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.service.business.base.controller"))
                .paths(PathSelectors.any())
                .build()
                .enable(enableSwagger)
                .apiInfo(new ApiInfoBuilder().version("1.0").title("Employee API").description("Documentation Employee API v1.0").build());
    }
}
